<template>
  <div class="index_wrap">
    <div class="index_wrap_left">
      <p class="titles"><i class="el-icon-s-opportunity"></i> 精选文章</p>
      <article class="tuijian_wrap" v-for="(item, index) in 6" :key="index">
        <img
          src="http://th.hzzy.xyz/wp-content/uploads/2021/11/back001.jpg"
          alt=""
        />
        <div class="post-content">
          <p>文章标题</p>
          <p>
            这是首页章节的范例。首页章节可以是除了首页本身以外的任何其他页面，包括显示最新博客文章的页面。超过三行三点显示超过三行三点显示超过三行三点显示超过三行三点显示超过三行三点显示
          </p>
          <p>
            <i class="el-icon-view"> 99</i>&nbsp;&nbsp;
            <i class="el-icon-thumb"> 88</i>&nbsp;&nbsp;
            <i class="el-icon-chat-round"> 66</i>
          </p>
          <p>查看详情</p>
          <div class="suspend_wrap">
            <div>
              <i class="el-icon-date"> &nbsp;2021年11月15日 &nbsp;&nbsp;|</i>
            </div>
            <div>
              <i class="el-icon-date"> &nbsp;2021年11月15日 &nbsp;&nbsp;|</i>
            </div>
            <div><i class="el-icon-folder-opened"></i></div>
          </div>
        </div>
      </article>
      <p class="more_wrap"><b>查看更多</b></p>
    </div>
    <div class="index_wrap_right">
      <div :class="{ fixed_search: fixedSearch }">
        <div class="right_wrap1">
          <p>搜索</p>
          <div class="search_wrap">
            <input type="text" name="" id="" placeholder="搜索博客" />
            <span><i class="el-icon-search"></i></span>
          </div>
        </div>
        <div class="right_wrap2">
          <p>意见反馈</p>
          <div class="search_wrap">
            <textarea
              maxlength="100"
              placeholder="写下您宝贵的意见!"
            ></textarea>
            <p>提交</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "BlogsIndex",

  data() {
    return {
      fixedSearch: false,
    };
  },

  mounted() {
    window.addEventListener("scroll", this.handleScroll);
  },

  methods: {
    handleScroll() {
      var scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop;
      scrollTop >= 290 ? (this.fixedSearch = true) : (this.fixedSearch = false);
    },
  },
};
</script>

<style lang="scss" scoped>
.index_wrap {
  width: 1110px;
  margin: 0 auto;
  min-height: 800px;
  display: flex;
  justify-content: space-between;

  .index_wrap_left {
    width: 730px;
    height: auto;

    .titles {
      margin: 30px 0;
      font-size: 22px;
      font-weight: bold;

      > i {
        color: #ff6a3e;
      }
    }

    .tuijian_wrap {
      padding: 10px;
      box-sizing: border-box;
      width: 730px;
      height: auto;
      position: relative;
      padding: 10px 10px;
      box-shadow: 0px 0px 25px 0px rgba(0, 0, 0, 0.085);
      background: #fff;
      margin-top: 4px;
      margin-bottom: 40px;
      border-radius: 5px;

      > img {
        width: 100%;
        height: auto;
      }

      .post-content {
        padding: 0 30px 30px;
        color: #111111;
        font-weight: 400;
        line-height: 1.75;
        font-size: 1rem;
        position: relative;
        > p:nth-child(1) {
          font-weight: bold;
          font-size: 24px;
        }

        > p:nth-child(2) {
          overflow: hidden;
          text-overflow: ellipsis;
          word-break: break-all;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }

        > p:nth-child(3) {
          color: #7a7a7a;
          > i {
            cursor: pointer;
          }
        }

        > p:nth-child(4) {
          cursor: pointer;
          width: 150px;
          height: 40px;
          background: #ff6a3e;
          border-radius: 5px;
          line-height: 40px;
          text-align: center;
          color: #fff;
          font-size: 16px;
          font-weight: 800;
        }

        .suspend_wrap {
          padding: 0 15px;
          box-sizing: border-box;
          display: flex;
          justify-content: flex-start;
          align-items: center;
          color: #fff;
          transition: all 0.5s;
          opacity: 0;
          position: absolute;
          top: -65px;
          left: 40px;
          width: 630px;
          height: 50px;
          background: #ff6a3e;
          border-bottom-left-radius: 20px;
          border-top-right-radius: 20px;

          > div {
            font-size: 13px;
            margin: 0 10px;
          }
        }
      }
    }

    .tuijian_wrap:hover {
      .post-content {
        .suspend_wrap {
          top: -55px;
          position: absolute;
          opacity: 1;
          top: -55px;
          left: 40px;
          width: 630px;
          height: 50px;
          background: #ff6a3e;
          border-bottom-left-radius: 20px;
          border-top-right-radius: 20px;
        }
      }
    }
  }

  .fixed_search {
    position: fixed;
    top: 80px;
  }

  .index_wrap_right {
    box-sizing: border-box;
    position: relative;
    width: 350px;
    height: 500px;

    > div {
      > .right_wrap1 {
        margin: 90px 0 20px 0;
        width: 350px;
        height: 138px;
        box-shadow: 0 0 29px 0 hsla(0, 0%, 40%, 0.1);

        > p:nth-child(1) {
          box-sizing: border-box;
          padding-left: 20px;
          background: rgb(219, 219, 219);
          font-size: 22px;
          font-weight: bold;
          width: 100%;
          height: 46px;
          line-height: 46px;
          border-left: 3px solid #ff6a3e;
        }

        .search_wrap {
          width: 310px;
          height: 52px;
          display: flex;
          align-items: center;
          justify-content: flex-start;
          padding: 0 0 0 20px;

          > input {
            padding: 0 10px;
            width: 80%;
            height: 52px;
            border: 1px solid #c0c0c0;
            border-right: 0px;
            border-top-left-radius: 4px;
            border-bottom-left-radius: 4px;
          }

          > input:focus {
            border: 1px solid #ff6a3e;
          }

          > span {
            cursor: pointer;
            border-top-right-radius: 4px;
            border-bottom-right-radius: 4px;
            background: #ff6a3e;
            width: 56px;
            height: 55px;
            text-align: center;
            line-height: 55px;
            font-size: 20px;
            color: #fff;
          }
        }
      }
      > .right_wrap2 {
        margin: 60px 0 20px 0;
        width: 350px;
        height: 338px;
        box-sizing: border-box;
        box-shadow: 0 0 29px 0 hsla(0, 0%, 40%, 0.1);
        > p:nth-child(1) {
          box-sizing: border-box;
          padding-left: 20px;
          background: rgb(219, 219, 219);
          font-size: 22px;
          font-weight: bold;
          width: 100%;
          height: 46px;
          line-height: 46px;
          border-left: 3px solid #ff6a3e;
        }
        .search_wrap {
          text-align: center;
          box-sizing: border-box;
          padding: 5px 15px;
          > textarea {
            width: 100%;
            height: 150px;
            border: none;
            border-radius: 5px;
            font-size: 18px;
            resize: none;
          }
          > p {
            margin: 20px auto;
            cursor: pointer;
            width: 150px;
            height: 40px;
            background: #ff6a3e;
            border-radius: 5px;
            line-height: 40px;
            text-align: center;
            color: #fff;
            font-size: 16px;
            font-weight: 800;
          }
        }
      }
    }
  }
}

// 适配手机端
@media screen and (min-width: 1000px) and (max-width: 1120px) {
  .index_wrap {
    width: 860px;
    margin: 0 auto;
    min-height: 800px;
    display: flex;
    justify-content: space-between;

    .index_wrap_left {
      width: 730px;
      height: auto;

      .tuijian_wrap {
        padding: 10px;
        box-sizing: border-box;
        width: 530px;
        height: auto;
        position: relative;
        padding: 10px 10px;
        box-shadow: 0px 0px 25px 0px rgba(0, 0, 0, 0.085);
        background: #fff;
        margin-top: 4px;
        margin-bottom: 40px;
        border-radius: 5px;

        > img {
          width: 100%;
          height: auto;
        }

        .post-content {
          padding: 0 30px 30px;
          color: #111111;
          font-weight: 400;
          line-height: 1.75;
          font-size: 1rem;
          position: relative;

          > p:nth-child(1) {
            font-weight: bold;
            font-size: 24px;
          }

          > p:nth-child(2) {
            overflow: hidden;
            text-overflow: ellipsis;
            word-break: break-all;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }

          > p:nth-child(3) {
            color: #7a7a7a;
            > i {
              cursor: pointer;
            }
          }

          > p:nth-child(4) {
            cursor: pointer;
            width: 150px;
            height: 40px;
            background: #ff6a3e;
            border-radius: 5px;
            line-height: 40px;
            text-align: center;
            color: #fff;
            font-size: 16px;
            font-weight: 800;
          }

          .suspend_wrap {
            padding: 0 15px;
            box-sizing: border-box;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            color: #fff;
            transition: all 0.5s;
            opacity: 0;
            position: absolute;
            top: -65px;
            left: 40px;
            width: 430px;
            height: 50px;
            background: #ff6a3e;
            border-bottom-left-radius: 20px;
            border-top-right-radius: 20px;

            > div {
              font-size: 13px;
              margin: 0 10px;
            }
          }
        }
      }
      .tuijian_wrap:hover {
        .post-content {
          .suspend_wrap {
            top: -55px;
            position: absolute;
            opacity: 1;
            top: -55px;
            left: 40px;
            width: 430px;
            height: 50px;
            background: #ff6a3e;
            border-bottom-left-radius: 20px;
            border-top-right-radius: 20px;
          }
        }
      }
    }

    .fixed_search {
      position: fixed;
      top: 80px;
      right: 50px;
    }

    .index_wrap_right {
      box-sizing: border-box;
      position: relative;
      width: 300px;
      height: 500px;

      > div {
        > .right_wrap1 {
          margin: 90px 0 20px 0;
          width: 300px;
          height: 138px;
          box-shadow: 0 0 29px 0 hsla(0, 0%, 40%, 0.1);

          > p:nth-child(1) {
            box-sizing: border-box;
            padding-left: 20px;
            background: rgb(219, 219, 219);
            font-size: 22px;
            font-weight: bold;
            width: 100%;
            height: 46px;
            line-height: 46px;
            border-left: 3px solid #ff6a3e;
          }

          .search_wrap {
            width: 280px;
            height: 52px;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            padding: 0 0 0 20px;

            > input {
              padding: 0 10px;
              width: 70%;
              height: 52px;
              border: 1px solid #c0c0c0;
              border-right: 0px;
              border-top-left-radius: 4px;
              border-bottom-left-radius: 4px;
            }

            > input:focus {
              border: 1px solid #ff6a3e;
            }

            > span {
              cursor: pointer;
              border-top-right-radius: 4px;
              border-bottom-right-radius: 4px;
              background: #ff6a3e;
              width: 56px;
              height: 55px;
              text-align: center;
              line-height: 55px;
              font-size: 20px;
              color: #fff;
            }
          }
        }
        > .right_wrap2 {
          margin: 60px 0 20px 0;
          width: 300px;
          height: 338px;
          box-sizing: border-box;
          box-shadow: 0 0 29px 0 hsla(0, 0%, 40%, 0.1);
          > p:nth-child(1) {
            box-sizing: border-box;
            padding-left: 20px;
            background: rgb(219, 219, 219);
            font-size: 22px;
            font-weight: bold;
            width: 100%;
            height: 46px;
            line-height: 46px;
            border-left: 3px solid #ff6a3e;
          }
          .search_wrap {
            text-align: center;
            box-sizing: border-box;
            padding: 5px 15px;
            > textarea {
              width: 100%;
              height: 150px;
              border: none;
              // border: 1px solid #ff5500!important;
              border-radius: 5px;
              font-size: 18px;
              resize: none;
            }
            > p {
              margin: 20px auto;
              cursor: pointer;
              width: 150px;
              height: 40px;
              background: #ff6a3e;
              border-radius: 5px;
              line-height: 40px;
              text-align: center;
              color: #fff;
              font-size: 16px;
              font-weight: 800;
            }
          }
        }
      }
    }
  }
}

@media screen and (max-width: 1000px) {
  .index_wrap {
    width: 800px;
    margin: 0 auto;
    min-height: 800px;
    display: flex;
    justify-content: center;

    .index_wrap_left {
      width: 700px;
      height: auto;

      .titles {
        margin: 30px 0;
        font-size: 22px;
        font-weight: bold;

        > i {
          color: #ff6a3e;
        }
      }

      .tuijian_wrap {
        padding: 10px;
        box-sizing: border-box;
        width: 700px;
        height: auto;
        position: relative;
        padding: 10px 10px;
        box-shadow: 0px 0px 25px 0px rgba(0, 0, 0, 0.085);
        background: #fff;
        margin-top: 4px;
        margin-bottom: 40px;
        border-radius: 5px;

        > img {
          width: 100%;
          height: auto;
        }

        .post-content {
          padding: 0 30px 30px;
          color: #111111;
          font-weight: 400;
          line-height: 1.75;
          font-size: 1rem;
          position: relative;

          > p:nth-child(1) {
            font-weight: bold;
            font-size: 24px;
          }

          > p:nth-child(2) {
            overflow: hidden;
            text-overflow: ellipsis;
            word-break: break-all;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }

          > p:nth-child(3) {
            color: #7a7a7a;
            font-size: 22px;
            > i {
              cursor: pointer;
            }
          }

          > p:nth-child(4) {
            cursor: pointer;
            width: 160px;
            height: 48px;
            background: #ff6a3e;
            border-radius: 5px;
            line-height: 48px;
            text-align: center;
            color: #fff;
            font-size: 16px;
            font-weight: 800;
          }

          .suspend_wrap {
            padding: 0 15px;
            box-sizing: border-box;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            color: #fff;
            transition: all 0.5s;
            opacity: 0;
            position: absolute;
            top: -65px;
            left: 40px;
            width: 630px;
            height: 50px;
            background: #ff6a3e;
            border-bottom-left-radius: 20px;
            border-top-right-radius: 20px;

            > div {
              font-size: 13px;
              margin: 0 10px;
            }
          }
        }
      }
      .tuijian_wrap:hover {
        .post-content {
          .suspend_wrap {
            top: -55px;
            position: absolute;
            opacity: 1;
            top: -55px;
            left: 40px;
            width: 630px;
            height: 50px;
            background: #ff6a3e;
            border-bottom-left-radius: 20px;
            border-top-right-radius: 20px;
          }
        }
      }
    }

    .fixed_search {
      position: fixed;
      top: 80px;
    }

    .index_wrap_right {
      display: none;
    }
  }
}

.fixedwrap {
  position: fixed;
}
.more_wrap {
  margin: 20px 0;
  cursor: pointer;
  text-align: center;
  > b {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.12);
    color: #55aaff;
    border-radius: 10px;
    padding: 12px 25px;
  }
}
</style>
